unit basicio_player;

{$mode objfpc}{$H+}

{
  stores all information about a specific player
}

interface

uses
  Classes, SysUtils, fgl, basicio_resources, Graphics;

type              //DO NOT CHANGE ORDER!
  TPlayerColor = (PC_White, PC_Yellow, PC_Blue, PC_Red, PC_Unknown);

type
  TBuyable = record
    Cities: Integer;
    Cities_extended: Integer;
    Streets: Integer;
    Inventions: Integer;
  end;
  TPlayerResources = record
    Knights: integer;
    Winpoints: integer;
    Monopolies: integer;
    Streets: integer;
    Inventions: integer;
  end;

  { TPlayer }
  TPlayer = class
    private
      FBuyable: TBuyable;
      FResources: TResources;
      FPlayerResources: TPlayerResources;
      FColor: TPlayerColor;
    public
      property Buyable: TBuyable read FBuyable write FBuyable;
      property Resources: TResources read FResources write FResources;
      property PlayerResources: TPlayerResources read FPlayerResources write FPlayerResources;
      property Color: TPlayerColor read FColor write FColor;
    public
      constructor Create(AColor: TPlayerColor);
      destructor Destroy; override;
  end;

  TPlayerList = specialize TFPGObjectList<TPlayer>;

function PlayerColorToColor(a: TPlayerColor): TColor;

implementation

function PlayerColorToColor(a: TPlayerColor): TColor;
begin
  case a of
    PC_White: result  := clgray;
    PC_Yellow:result  := clyellow;
    PC_Blue:  result  := clblue;
    PC_Red:   result  := clred;
    PC_Unknown:result := clnone;
  end;
end;

{ TPlayer }

constructor TPlayer.Create(AColor: TPlayerColor);
begin
  inherited Create;

  //Resources
  FResources.dirt  := 0;
  FResources.ore   := 0;
  FResources.sheeps:= 0;
  FResources.wheat := 0;
  FResources.wood  := 0;
  FPlayerResources.knights    := 0;
  FPlayerResources.winpoints  := 0;
  FPlayerResources.monopolies := 0;
  FPlayerResources.streets    := 0;
  FPlayerResources.Inventions := 0;

  //Buyables
  FBuyable.Cities          := 0;
  FBuyable.inventions      := 0;
  FBuyable.streets         := 0;
  FBuyable.Cities_extended := 0;

  FColor := AColor;
end;

destructor TPlayer.Destroy;
begin
  inherited Destroy;
end;

end.

